from PyQt5.QtWidgets import QApplication, QMainWindow, QScrollArea, QDockWidget, QFileDialog, QMessageBox, QColorDialog, QDialog, QGridLayout, QLabel, QButtonGroup, QRadioButton, QDialogButtonBox, QWidget
from PyQt5.QtGui import QIcon, QColor, QImage, QPixmap
import sys
from configparser import ConfigParser
from PyQt5.QtCore import Qt
from otherWidgets import SWQTDocker, SettingsDialog
from utils import create_action, npndarray2qimage, messageBox_info
import numpy as np
import cv2
import os
from volumeMeasure import VolumeMeasure
from PyQt5.QtMultimedia import QCameraInfo
#a swqt target at cursor point and number told
class SWQT1(QMainWindow):
    def __init__(self, pic, paramlist, parent=None):
        super(SWQT1, self).__init__(parent)
        self.pic = pic
        self.paramlist = paramlist
        self.setMouseTracking(True)
        self.initUI()

    def initUI(self):
        label = QLabel(self)
        label.setPixmap(QPixmap.fromImage(npndarray2qimage(self.pic)))
        self.setCentralWidget(label)

        self.status = self.statusBar()

    def mouseMoveEvent(self, e):
        self.setMouseTracking(True)
        x = e.pos().x()
        y = e.pos().y()
        if y <430 and x<590:
            d = self.paramlist[0][y][x]
            if d <= 0:
                img3d=[-1, -1, -1]
            else:
                img3d = self.paramlist[1][y][x]
        else:
            d=0
            img3d=[0, 0, 0]
        # print(img3d, d)
        # if y<430 and x < 590:
        #     displv = self.paramlist[0][y][x]
        #     truedisplv = self.paramlist[2][y][x]
        #     img3d = self.paramlist[3][y][x]
        # else:
        #     displv = self.paramlist[1][y][x-590]
        #     truedisplv = 0
        #     img3d = [0, 0, 0]
        #self.status.showMessage('%d, %d, %f, %f, %f, %f, %f'%(x, y, displv, truedisplv, img3d[0], img3d[1], img3d[2]))
        self.status.showMessage('%d, %d, %d, %f, %f, %f'%(x, y, d, img3d[0], img3d[1], img3d[2]))